﻿namespace AntdUI_HamburgerMenuTabs.Pages
{
    public partial class Settings : UserControl
    {
        public Settings()
        {
            InitializeComponent();
        }

        public Settings(FrmMain? frmMain)
        {
            InitializeComponent();

            #region 添加示例选项（流式布局）
            gridPanel1.SuspendLayout();
            for (int i = 0; i < 20; i++)
            {
                gridPanel1.Span += ";100%";
                gridPanel1.Height += 50;
                AntdUI.Button btn = new()
                {
                    Name = $"btn{i + 1}",
                    Text = $"按钮{i + 1:000}",
                    Type = AntdUI.TTypeMini.Primary,
                };
                gridPanel1.Controls.Add(btn);
                btn.BringToFront();
            }
            gridPanel1.ResumeLayout();
            #endregion

            #region 初始化选项：过渡动画
            switchAnimation.Checked = AntdUI.Config.Animation;

            switchAnimation.CheckedChanged += (s, e) =>
            {
                AntdUI.Config.Animation = switchAnimation.Checked;
            };
            #endregion

            #region 初始化选项：页面模式
            bool flagPageMode = true;
            if (frmMain != null) switchPageMode.Checked = frmMain.MultiTabs;
            flagPageMode = false;

            switchPageMode.CheckedChanged += (s, e) =>
            {
                if (!flagPageMode)
                {
                    if (switchPageMode.Checked)
                    {
                        frmMain?.InitHm(true);
                    }
                    else
                    {
                        frmMain?.InitHm(false);
                    }
                }
            };
            #endregion

            btnClose.Click += (s, e) =>
            {
                Dispose();
            };
        }
    }
}